﻿using DreamCMS.WebCore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DreamCMS.Entity
{
    public class TagInfo:IComparable<TagInfo>
    {

        public int CompareTo(TagInfo other)
        {
            if(this.displayorder!=other.displayorder)
            {
                return this.displayorder.CompareTo(other.displayorder);
            }
            return this.tagid.CompareTo(other.tagid);
        }
        private long tagid;

        public long Tagid
        {
            get { return tagid; }
            set { tagid = value; }
        }
        private string name;
        /// <summary>
        /// 标签的名字
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        private string slug;

        public string Slug
        {
            get { return slug; }
            set { slug = value; }
        }
        private string description;

        public string Description
        {
            get { return description; }
            set { description = value; }
        }
        private long displayorder;

        public long Displayorder
        {
            get { return displayorder; }
            set { displayorder = value; }
        }
        private long postcount;
        /// <summary>
        /// 该标签对应的文章数量
        /// </summary>
        public long Postcount
        {
            get { return postcount; }
            set { postcount = value; }
        }
        private DateTime createdate;

        public DateTime Createdate
        {
            get { return createdate; }
            set { createdate = value; }
        }



        public string Url
        {
            get
            {
                string url = RequestHelper.SiteUrl + "tag.aspx?tag={0}";
                if(string.IsNullOrEmpty(this.slug))
                {
                    return string.Format(url, this.slug);
                }
                return string.Format(url, this.tagid);
            }
        }

        public string Link
        {
            get
            {
                string link = "<a href=\"{0}\" title=\"{1}\">{1}</a>";
                return string.Format(link, this.Url, this.name);
            }
        }
    }
}
